const express = require('express')
const { multer, dirMul, cpUpload } = require('../../model/tools')


const router = express.Router()

router.get('/', (req, res) => {
  res.render("admin/nav", {})
})


// router.post('/add', multer.single('pic'), (req, res) => {
//   var { title, desc } = req.body
//   console.log(req.body, req.file)
//   res.send('增加导航' + title + '--' + desc)
// })

// 动态目录上传图片
// router.post('/add', dirMul.single('pic'), (req, res) => {
//   var { title, desc } = req.body
//   console.log(req.body, req.file)
//   res.send('增加导航' + title + '--' + desc)
// })


// 多文件上传
router.post('/add', cpUpload, (req, res) => {
  var { title, desc } = req.body
  console.log(req.body, req.file)
  res.send({
    body: req.body,
    files: req.files
  })
})


router.get('/edit', (req, res) => {
  res.send('修改导航')
})

module.exports = router